package my.utils.markdown.markdownformat.filter;

import org.apache.commons.io.filefilter.AbstractFileFilter;
import org.apache.commons.lang3.StringUtils;

import java.io.File;

public class MarkdownFilter extends AbstractFileFilter {
    @Override
    public boolean accept(File file) {
        //得到文件名
        String fileName = file.getName();
        //防止将一些插件的说明、版权、更新文档转为pdf
        if (
                StringUtils.containsIgnoreCase(fileName,"LICENSE")||
                StringUtils.containsIgnoreCase(fileName,"README")||
                StringUtils.containsIgnoreCase(fileName,"CHANGES")||
                StringUtils.containsIgnoreCase(fileName,"CONTRIBUTING")||
                StringUtils.containsIgnoreCase(fileName,"HELP")||
                StringUtils.containsIgnoreCase(fileName,"CHANGELOG")
        ) {
            return false;
        } else {
            return fileName.endsWith(".md");
        }
    }
}
